'use strict';
//连接数据库
const db = uniCloud.database();
exports.main = async (event, context) => {

	//选择操作数据集合
	const collection = db.collection('videos')

	//接收前端提交过来的数据
	//用户名
	let username = event.username
	//头像
	let avatar = event.avatar
	//
	let openid = event.openid
	//视频
	let video = event.video
	//标题
	let title = event.title
	//分类id
	let cateid = event.cateid

	//将数据插入表中
	collection.add({
		openid,
		username,
		avatar,
		video,
		title,
		cateid,
		//发布时间
		addtime: Date.now()
	})
	//返回数据给客户端
	return {
		ok: 200
	}
};
